package com.hinner.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.hinner.common.Result;
import com.hinner.entity.fenbushi.FbsLineMain;
import com.hinner.entity.fenbushi.dto.JgdwDTO;
import com.hinner.entity.fenbushi.vo.JgdwVO;
import com.hinner.service.FbsLineMainService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/fbslinemain")
public class FbsLineMainController {

    @Autowired
    private FbsLineMainService fbsLineMainService;

    /**
     * 根据监管单位id，查询所有线路信息。
     * @param jgdwId
     * @return
     */
    @GetMapping("/lines/{jgdwId}")
    public Result getAllLineByJgdwId(@PathVariable("jgdwId") String jgdwId){
        return Result.success(fbsLineMainService.getAllLineByJgdwId(jgdwId));
    }

    /**
     * 根据省份获取所有的监管单位信息
     * @param provinceCode
     * @return
     */
    @GetMapping("/jgdw/{provinceCode}")
    public Result getAllJgdwByPc(@PathVariable("provinceCode") String provinceCode){
        return Result.success(fbsLineMainService.getAllJgdwByPc(provinceCode));
    }

    /**
     * 新增监管单位
     * @return
     */
    @PostMapping("/addJgdw")
    public Result addJgdw(@RequestBody JgdwDTO dto){
        fbsLineMainService.addJgdw(dto);
        return Result.success();
    }

    @DeleteMapping("/jgdw/{id}")
    public Result deleteJgdw(@PathVariable("id") String id){
        return Result.success(fbsLineMainService.removeById(Long.parseLong(id)));
    }
}
